﻿using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xejen.Logger.Log4Net
{
    /// <summary>
    /// 表示仅适用于Log4Net的日志管理 
    /// </summary>
    /// <creator>marc</creator>
    public sealed class Log4NetManager
    {
        private static ILoggerManager _instance;
        private static ILogConfigurationService _configService;

        /// <inheritdoc cref="Log4NetManager"/>
        private Log4NetManager()
        {
        }

        /// <summary>
        /// 表示<see cref="LoggerManager{TLoggerFactory}"/>的实例
        /// </summary>
        public static ILoggerManager Instance(ILogConfigurationService configService = null)
        {
            if (_instance == null)
            {
                _configService = configService ?? new Log4NetConfigurationService();
                _configService.Configure();
                _instance = new LoggerManager(new Log4NetLoggerFactory());
            }

            return _instance;
        }

        /// <summary>
        /// 表示<see cref="LoggerManager{TLoggerFactory}"/>的实例
        /// </summary>
        /// <param name="options"><inheritdoc cref="Log4NetProviderOptions" path="/summary"/></param>
        public static ILoggerManager Instance(Log4NetProviderOptions options)
        {
            if (_instance == null)
            {
                _instance = new LoggerManager(new Log4NetLoggerFactory(options));
            }

            return _instance;
        }
    }
}
